Skip to content

feat: reduce AI context token consumption by collapsing successful bu…#2

Merged
killme2008 merged 3 commits intomainfrom
feature/collapse-response
Feb 7, 2026
Merged

feat: reduce AI context token consumption by collapsing successful bu…#2
killme2008 merged 3 commits intomainfrom
feature/collapse-response

Conversation

@killme2008
Copy link
Owner

…ilds, using tail-biased truncation, and relaxing verbatim output instructions

…ilds, using tail-biased truncation, and relaxing verbatim output instructions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@killme2008
Copy link
Owner Author

@copilot review it

Copy link

Copilot AI commented Feb 7, 2026

@killme2008 I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces AI context usage from devtap drains by collapsing successful runs into a single summary line, biasing truncation toward the tail of logs, and relaxing “verbatim output” instructions for successful builds.

Changes:

  • Add mcp.CollapseSuccessful to replace successful run output (exit code 0) with a single-line omission summary.
  • Switch message truncation to use tail-biased truncation (TruncateWithRatio(..., 0.8)) to preserve end-of-log errors.
  • Update MCP/tooling instructions/docs to acknowledge successes briefly and only show verbatim output on failures.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
skills/devtap-get-build-errors/SKILL.md Updates skill guidance to avoid repeating successful output and keep failures verbatim.
internal/mcp/truncate.go Uses tail-biased truncation for per-message line truncation.
internal/mcp/server.go Updates tool description and collapses successful runs before truncation/formatting.
internal/mcp/collapse.go Implements collapsing of successful runs into a single summary line.
internal/mcp/collapse_test.go Adds unit tests covering collapse behavior across multiple run/tag scenarios.
internal/filter/truncate.go Introduces TruncateWithRatio and redefines Truncate as a 50/50 wrapper.
internal/filter/truncate_test.go Adds tests for tail-biased truncation and edge cases.
internal/adapter/instructions.go Updates injected instruction block to not repeat successful output.
cmd/devtap/drain.go Collapses successful runs before truncation in CLI drain paths.
CLAUDE.md Updates documented output expectations for successful vs failed builds.
Comments suppressed due to low confidence (1)

internal/filter/truncate.go:50

  • TruncateWithRatio can return maxLines + 1 entries when truncation occurs because it adds an omission marker in addition to head+tail==maxLines. This means callers like mcp.TruncateMessages can exceed their overall line budget (and may clear later messages earlier than intended). If maxLines is meant to be a hard cap, adjust the algorithm so the omission marker is included in the budget (e.g., reserve 1 line for the marker and use head+tail=maxLines-1 when truncating).
	omitted := len(lines) - head - tail
	result := make([]string, 0, head+1+tail)
	result = append(result, lines[:head]...)
	result = append(result, fmt.Sprintf("... (%d lines omitted)", omitted))
	result = append(result, lines[len(lines)-tail:]...)


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
@killme2008 killme2008 merged commit e378803 into main Feb 7, 2026
3 checks passed
@killme2008 killme2008 deleted the feature/collapse-response branch February 7, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants